<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            var isSubsequence = function (s, t) {
                let dp = new Array(s.length + 1).fill().map(() => new Array(t.length + 1).fill(false))
                for (let j = 0; j <= t.length; j++) {
                    dp[0][j] = true
                }
                for (let i = 1; i <= s.length; i++) {
                    for (let j = 1; j <= t.length; j++) {
                        if (s[i - 1] == t[j - 1]) {
                            dp[i][j] = dp[i - 1][j - 1]
                        } else {
                            dp[i][j] = dp[i][j - 1]
                        }
                    }
                }
                return dp[s.length][t.length]
            }
            isSubsequence('abc', 'ahbgdc')
        </script>
    </body>
</html>
